/*
 * Notes:
 * 1. use AUTO strategy for the id generating, ok or not?
 * 2. to-do: relationship field with case
 */
package entity;

import java.io.Serializable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

/**
 *
 * @author Ye Mei
 */
@Entity(name="CaseHistory")
public class CaseHistoryEntity implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private String id;
    private String dateEntry;
    private String description;

    public CaseHistoryEntity() {
    }

    public void create(String description) {
        this.setDateEntry();
        this.description = description;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getDateEntry() {
        return dateEntry;
    }

    public void setDateEntry() {
        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        this.dateEntry = dateFormat.format(new Date());
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CaseHistoryEntity)) {
            return false;
        }
        CaseHistoryEntity other = (CaseHistoryEntity) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.CaseHistoryEntity[ id=" + id + " ]";
    }
    
}
